package com.woniuxy.controller;


import com.woniuxy.controller.form.RuleMenueForm;
import com.woniuxy.controller.info.MenuesIdInfo;
import com.woniuxy.exception.DdException;
import com.woniuxy.service.RoleMenusService;
import com.woniuxy.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hujianying
 * @since 2022-03-29
 */
@RestController
@RequestMapping("/roleMenus")
@Api(tags = "菜单相关接口")
public class RoleMenusController {

    @Resource
    private RoleMenusService ruleMenusService;

    //根据角色ID获取菜单id数组
    @GetMapping("/findMenuesId")
    @ApiOperation("根据角色ID获取菜单id数组")
    public Result findMenuesId(Integer id){
        MenuesIdInfo menuesId = ruleMenusService.findMenuesId(id);
        return Result.success(200,"请求成功",menuesId.getMenuesId());
    }

    //根据角色id和menueid数组修改数据库
    @PostMapping("/updateRuleMenues")
    @ApiOperation("根据角色id和menueid数组修改数据库")
    public Result updateRuleMenues(@RequestBody RuleMenueForm rmf) throws DdException {
        ruleMenusService.updateRuleMenues(rmf);
        return Result.success(200,"修改成功",null);
    }

}

